$(function(){
	var tab_counter = 1;
	// Heaedr
	$('#webHeader').tabs();
	// Accordion
	$("#accordion").accordion({ header: "h3" });

	// Tabs
	$('#tabs').tabs();
	
	// actual addTab function: adds new tab using the title input from the form above
	function addTab() {
		var tab_title = "Nueva " + tab_counter;
		$tabs.tabs( "add", "#tabs-" + tab_counter, tab_title );
		tab_counter++;
	}
	// close icon: removing the tab on click
	// note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
	$( "#tabs span.ui-icon-close" ).live( "click", function() {
		var index = $( "li", $tabs ).index( $( this ).parent() );
		$tabs.tabs( "remove", index );
	});

	// Dialog			
	$('#dialog').dialog({
		autoOpen: false,
		width: 600,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close"); 
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
	
	// Dialog Link
	$('#dialog_link').click(function(){
		$('#dialog').dialog('open');
		return false;
	});

	// Datepicker
	$('#datepicker').datepicker({
		inline: true
	});
	
	// Slider
	$('#slider').slider({
		range: true,
		values: [17, 67]
	});
	
	// Progressbar
	$("#progressbar").progressbar({
		value: 20 
	});
	
	$("#browser1").treeview();
	$("#browser2").treeview();
	
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	$("#arrow").click(function(){
		if($("#left").css("display")=='none'){
			$("#left").css("display","block");
			$("#right").css("width","78%");
		}else{
			$("#left").css("display","none");
			$("#right").css("width","98%");
		}
	});
	
});